var t = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/regenerator")), e = require("../../@babel/runtime/helpers/asyncToGenerator"), n = (require("../../utils/tool"), 
getApp());

Component({
    properties: {
        singInfo: {
            type: Object
        },
        isLogin: {
            type: Boolean,
            value: !1
        }
    },
    data: {
        month: null,
        singTmplIds: "BaPkq-_Q5XhXcxRW3z9PUGt24mj-mX5oBOsCP9yFAmo"
    },
    attached: function() {
        this.getCurrentMonth();
    },
    methods: {
        getCurrentMonth: function() {
            var t = new Date().getMonth() + 1;
            this.setData({
                month: t
            });
        },
        tapping: function() {
            this.triggerEvent("tappingSingIn", {});
        },
        tappingRules: function() {
            this.triggerEvent("tappingRules", {});
        },
        sign: function() {
            var i = this;
            return e(t.default.mark(function e() {
                return t.default.wrap(function(t) {
                    for (;;) switch (t.prev = t.next) {
                      case 0:
                        n.global.isLogin() ? wx.getSetting({
                            withSubscriptions: !0,
                            success: function(t) {
                                var e = t.subscriptionsSetting.itemSettings;
                                e && "accept" === e[i.data.singTmplIds] ? i.triggerEvent("tappingSingIn", {}) : wx.requestSubscribeMessage({
                                    tmplIds: [ i.data.singTmplIds ],
                                    success: function(t) {
                                        i.triggerEvent("tappingSingIn", {});
                                    },
                                    fail: function(t) {
                                        i.triggerEvent("tappingSingIn", {});
                                    }
                                });
                            }
                        }) : n.global.loginThenRedirectTo();

                      case 1:
                      case "end":
                        return t.stop();
                    }
                }, e);
            }))();
        },
        toLogin: function() {
            n.global.loginThenRedirectTo();
        }
    }
});